<?php if (!defined('BASEPATH')) exit('No direct script access allowed'); ?>
<?php $this->load->view('common/head'); ?>

<?php $this->load->view('common/header'); ?>
<div class="main-container" id="main-container">
    <script type="text/javascript">
        try {
            ace.settings.check('main-container', 'fixed')
        } catch (e) {
        }
    </script>

    <?php $this->load->view('common/sidebar'); ?>
    <div class="main-content">
        <div class="main-content-inner">
            <!-- #section:basics/content.breadcrumbs -->
            <?php $this->load->view('common/breadcrumbs'); ?>

            <!-- /section:basics/content.breadcrumbs -->
            <div class="page-content">

                <?php $this->load->view('common/set'); ?>

                <!-- /section:settings.box -->
                <div class="row">
                    <div class="col-xs-12">
                        <!-- PAGE CONTENT BEGINS -->
                        <div class="row">
                            <div class="cf">
                                <a class="btn btn-info" href="<?php echo site_url(X_URL . 'menu/add'); ?>"
                                   value="">新增</a>
                            </div>
                            <div class="space-4"></div>
                            <form id="form" method="post" action="<?php echo site_url(X_URL . 'menu/del'); ?>">
                                <table class="table table-striped table-bordered table-hover">
                                    <thead>
                                    <tr>
                                        <th class="center"><input class="check-all" type="checkbox" value=""></th>
                                        <th>菜单名称</th>
                                        <th>链接</th>
                                        <th>ICON</th>
                                        <th class="center">状态</th>
                                        <th>排序</th>
                                        <th class="center">操作</th>
                                    </tr>
                                    </thead>
                                    <tbody>
                                    <?php foreach ($authRule as $key => $val) { ?>
                                        <tr>
                                            <td class="center">
                                                <input class="ids" type="checkbox" name="ids[]" value="{$val['id']}">
                                            </td>
                                            <td><?php echo $val['title']; ?></td>
                                            <td><?php echo $val['name']; ?></td>
                                            <td><i class="menu-icon fa <?php echo $val['icon']; ?>"></i></td>
                                            <td class="center">
                                                <?php if ($val['islink'] == 1) { ?>显示<?php } else { ?>隐藏<?php } ?>
                                            </td>
                                            <td><?php echo $val['o']; ?></td>
                                            <td class="center"><a
                                                        href="<?php echo site_url(X_URL . 'menu/edit/' . $val['id']); ?>">修改</a>&nbsp;<a
                                                        class="del" href="javascript:;"
                                                        val="<?php echo site_url(X_URL . 'menu/del/' . $val['id']); ?>"
                                                        title="删除">删除</a></td>
                                        </tr>
                                        <?php if (!empty($val['children'])) { ?>
                                            <?php foreach ($val['children'] as $key => $v) { ?>
                                                <tr>
                                                    <td class="center">
                                                        <input class="ids" type="checkbox" name="ids[]"
                                                               value="{$v['id']}">
                                                    </td>
                                                    <td>┗━<?php echo $v['title']; ?></td>
                                                    <td><?php echo $v['name']; ?></td>
                                                    <td><i class="menu-icon fa <?php echo $v['icon']; ?>"></i></td>
                                                    <td class="center">
                                                        <?php if ($v['islink'] == 1) { ?>显示<?php } else { ?>隐藏<?php } ?>
                                                    </td>
                                                    <td><?php echo $v['o']; ?></td>
                                                    <td class="center"><a
                                                                href="<?php echo site_url(X_URL . 'menu/edit/' . $v['id']); ?>">修改</a>&nbsp;<a
                                                                class="del" href="javascript:;"
                                                                val="<?php echo site_url(X_URL . 'menu/del/' . $v['id']); ?>"
                                                                title="删除">删除</a></td>
                                                </tr>

                                                <?php if (!empty($v['children'])) { ?>
                                                    <?php foreach ($v['children'] as $key => $vv) { ?>
                                                        <tr>
                                                            <td class="center">
                                                                <input class="ids" type="checkbox" name="ids[]"
                                                                       value="{$vv['id']}">
                                                            </td>
                                                            <td>
                                                                &nbsp;&nbsp;&nbsp;&nbsp;┗━<?php echo $vv['title']; ?></td>
                                                            <td><?php echo $vv['name']; ?></td>
                                                            <td><i class="menu-icon fa <?php echo $vv['icon']; ?>"></i>
                                                            </td>
                                                            <td class="center">
                                                                <?php if ($vv['islink'] == 1) { ?>显示<?php } else { ?>隐藏<?php } ?>
                                                            </td>
                                                            <td><?php echo $vv['o']; ?></td>
                                                            <td class="center"><a
                                                                        href="<?php echo site_url(X_URL . 'menu/edit/' . $vv['id']); ?>">修改</a>&nbsp;<a
                                                                        class="del" href="javascript:;"
                                                                        val="<?php echo site_url(X_URL . 'menu/del/' . $vv['id']); ?>"
                                                                        title="删除">删除</a>
                                                            </td>
                                                        </tr>
                                                    <?php } ?>
                                                <?php } ?>
                                            <?php } ?>
                                        <?php } ?>
                                    <?php } ?>
                                    </tbody>

                                    </tbody>
                                </table>
                            </form>
                            <div class="cf">
                                <input id="submit" class="btn btn-info" type="button" value="删除">
                            </div>

                        </div>
                        <!-- PAGE CONTENT ENDS -->
                    </div><!-- /.col -->
                </div><!-- /.row -->
            </div><!-- /.page-content -->
        </div>
    </div><!-- /.main-content -->
    <?php $this->load->view('common/footer'); ?>
</div>


<?php $this->load->view('common/footerjs'); ?>
<!-- inline scripts related to this page -->
<script type="text/javascript">
    $(function () {
        $(".check-all").click(function () {
            $(".ids").prop("checked", this.checked);
        });
        $(".ids").click(function () {
            var option = $(".ids");
            option.each(function (i) {
                if (!this.checked) {
                    $(".check-all").prop("checked", false);
                    return false;
                } else {
                    $(".check-all").prop("checked", true);
                }
            });
        });
        $("#submit").click(function () {
            bootbox.confirm({
                title: "系统提示",
                message: "确定要删除所选？",
                callback: function (result) {
                    if (result) {
                        $("#form").submit();
                    }
                },
                buttons: {
                    "cancel": {"label": "取消"},
                    "confirm": {
                        "label": "确定",
                        "className": "btn-danger"
                    }
                }
            });
        });
        $(".del").click(function () {
            var url = $(this).attr('val');
            bootbox.confirm({
                title: "系统提示",
                message: "确定要删除?",
                callback: function (result) {
                    if (result) {
                        window.location.href = url;
                    }
                },
                buttons: {
                    "cancel": {"label": "取消"},
                    "confirm": {
                        "label": "确定",
                        "className": "btn-danger"
                    }
                }
            });
        });
    })
</script>
</body>
</html>
